<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {


//    return \App\Http\Resources\UserCollection::collection(\App\Http\Resources\User::all());


    return $request->user();

});



Route::namespace('Api')->group(function () {



    Route::get('index/banner','IndexController@banner');


    // 登录逻辑
    Route::post('auth/login','AuthenticateController@login');
    // 退出登录
    Route::delete('auth/logout','AuthenticateController@logout');

    Route::get('index','IndexController@index');

    // 书籍搜索
    Route::get('books/search','BooksController@search');


    // 我的书架
    Route::get('me/bookshelf','UsersController@bookshelf');


    // 热度排行
    Route::get('books/hot_list','BooksController@hotList');
    // 热门书籍
    Route::get('books/hot_books','BooksController@hotBooks');


    // 热门坑吧

    // 1 => 人数 2 => 帖子
    Route::get('bars/hot_bar','BarsController@hotBar');


    // 书架管理

    // 删除书架书籍
    Route::delete('bookshelf','BookShelfController@destroy');

    // 加入书架
    Route::post('bookshelf','BookShelfController@store');

    // 书架界面的搜索
    Route::get('bookshelf/search','BookShelfController@search');

    //热门连载

    // 热门完结

    Route::get('books/hot_update','BooksController@hotUpdate');


    Route::get('books/hot_complete','BooksController@hotComplete');


    // 获取推荐
    Route::get('positions/{position}/recommends','RecommendController@index');


    // 获取搜这本书的人还看
    Route::get('books/relative','BooksController@relative');

    // 统一处理api异常 --- 已完成

    // 新书排行

    Route::get('books/new_list','BooksController@newList');

    Route::get('book_types','BookTypesController@index');



    Route::get('books','BooksController@index');

    Route::get('sites','SitesController@index');

    Route::get('books/{book}/chapters','ChaptersController@index');

    Route::get('chapters/{chapter}/article','ArticlesController@show');


    // 写作模块

    // 获取用户的相关信息
    Route::get('users/{user}','UsersController@show');

    // 我的写作数据
    Route::get('me/writing','UsersController@getWritingInfo');

    // 我的作品
    Route::get('me/books','UsersController@getBooks');

    // 创建书籍
    Route::post('books','BooksController@store');

    // 创建章和卷
    Route::post('books/{book}/chapters','ChaptersController@store');

    // 图片上传
    Route::post('images','ImagesController@store');

    // 获取通知列表
    Route::get('notifications','NotificationsController@index');

    // 更新资料
    Route::put('users/{user}','UsersController@update');

    // 上传头像
    Route::post('users/uploadAvatar','UsersController@uploadAvatar');

    // 忘记密码修改密码
    Route::post('users/changePassword','UsersController@changePassword');

    // 发送验证码
    Route::post('seedCode','AuthenticateController@seedCode');

    // 获取个人的详细信息
    Route::get('me','UsersController@me');

    // 写作 - 保存文章
    Route::put('chapters/{chapter}/articles','ArticlesController@update');

    // 加入书架

//    Route::post('bookshelf','BookShelfController@store');

    // 拿出书架

    // 删除书籍
    Route::delete('books/{book}','BooksController@destroy');


    // 打赏

    // 回复评论
    Route::post('posts/{post}/comments','CommentsController@store');

    // 获取书下评论
    Route::get('posts','PostsController@index');

    // 获取鲜花榜
    Route::get('ranking_list/flowers_user','RankingListController@flowersUser');

    // 获取荣誉榜
    Route::get('ranking_list/rewarded_user','RankingListController@rewardedUser');


    // 获取所有的gift
    Route::get('gifts','GiftsController@index');

    // 给用户送礼
    Route::post('gifts/send','GiftsController@sendGift');

    // 获取最后更新的章节


    // 书单
    Route::post('book_collections','BookCollectionController@store');
    Route::get('book_collections','BookCollectionController@index');


    // 加入书籍到书单
    Route::post('book_collections/{collection}','BookListController@store');
    Route::delete('book_collections/{collection}','BookListController@destroy');
    // 获取书单的书籍
    Route::get('book_collections/{collection}','BookListController@index');
    Route::delete('book_collections/{collection}/book_list/{list}','BookListController@destroy');



});

